<?php

/**
 * Table/CollegeTable.php
 */

namespace RHX\Model\Table;

use Zend\Db\Adapter\Adapter;
use Zend\Db\TableGateway\AbstractTableGateway;
use Zend\Db\ResultSet\ResultSet;
use RHX\Model\Object\College;

class CollegeTable extends AbstractTableGateway {

    protected $table = 'rh_college';

    public function __construct(Adapter $adapter) {
	$this->adapter			 = $adapter;
	$this->resultSetPrototype	 = new ResultSet();
	$this->resultSetPrototype->setArrayObjectPrototype(new College());
	$this->initialize();
    }

    /**
     * Tous les collèges
     * 
     * @param string $order
     * @return ResultSet
     */
    public function getAll($order = 'id ASC') {
	return $this->select(function(\Zend\Db\Sql\Select $select)use($order) {
			    $select->order($order);
			});
    }

    /**
     * Collège
     * 
     * @param int $id
     * @return College
     */
    public function get($id) {
	return $this->select(array('id' => $id))
			->current();
    }

}

?>
